{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tushare as ts\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from dateutil.parser import parse\n",
    "from datetime import datetime\n",
    "from pandas.tseries.offsets import Hour,Day"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.7578910917950199"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col_name=['date','open','high','low','close','vol','ma5','ma10','ma20','ma60']\n",
    "cyb_hist_index = pd.read_csv('c:\\\\pythonCoding\\\\data\\\\index\\\\399006.csv',header=None,skiprows=1,names=col_name,index_col='date')\n",
    "cyb_hist_index.index = pd.to_datetime(cyb_hist_index.index)\n",
    "\n",
    "shanghai_gold_spot = pd.read_csv(\"c:\\\\pythoncoding\\\\data\\\\gold\\\\sh_gold_spot.csv\",index_col = \"date\")\n",
    "shanghai_gold_spot.index = pd.to_datetime(shanghai_gold_spot.index)\n",
    "\n",
    "cybVsGold = pd.merge(cyb_hist_index,shanghai_gold_spot,left_index=True,right_index=True)\n",
    "cybVsGold['close'].corr(cybVsGold['close:Au9999'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
